import React, { Component } from 'react'
import { 
    BrowserRouter, Link, Route, Switch, Redirect 
} from 'react-router-dom'
import { connect } from 'react-redux'

import Home from './Home'
import User from './User'

class Dashboard extends Component {
    render() {
        const { login } = this.props
        console.log(login)
        return (
            <div>
                Dashboard
                { login.isLogin === false && <Redirect to="/login" /> }
                <BrowserRouter>
                    <ul>
                        <li><Link to="/dashboard/home" >Home</Link></li>
                        <li><Link to="/dashboard/user" >User</Link></li>
                    </ul>
                    <Switch>    
                        <Route path="/dashboard/home" component={Home} />
                        <Route path="/dashboard/user" component={User} />
                    </Switch>
                </BrowserRouter>
            </div>
        )
    }
}

const mapStateToProps = state => ({
    login: state.login
})

export default connect(mapStateToProps)(Dashboard)